<?php
/**
 * order 订单类
 *
 * @author <judasnow@gmail.com>
 */
class order{

	private $_CI;
	private $_order_info;

	public function __construct( $order_info = '' ){
	
		$this->_CI =& get_instance();
		$this->_CI->load->model( 'order_model' , '' , TRUE );

		$this->_order_info = $order_info;
	}

	public function change_order_status( $new_status ){

		//有效的订单状态
		//DISPATCH 表示已经发货
		$valid_status = array( 'BUY' , 'PAID' , 'DISPATCH' , 'ABANDON' , 'DONE' );
		if( !in_array( $new_status , $valid_status ) ){
		
			 throw new LogicException( '无效的订单状态.' );
		}
		//修改内存中的对象
		//$this->_order_info['status'] = 'PAID';
		//修改数据库中的相关介绍
		$this->_CI->order_model->update( array( 'status'=>$new_status ) , 
			array( 'order_id'=>$this->_order_info['order_id'] ) );

		return TRUE;
	}
}
